package com.atguigu.bigdata.scala.chapter05

object Scala07_Function_Hell_7 {

    def main(args: Array[String]): Unit = {

        // TODO 函数式编程 - 地狱

        // 需求：传递2个Int类型的参数值，两个参数的计算逻辑不确定。需要从外部传递。
        def test( x : Int, y: Int, f : (Int, Int)=>Int ): Unit = {
            val result = f(x, y)
            println(result)
        }

//        test(10, 20, (x:Int, y:Int)=>{x + y})
//        test(10, 20, (x:Int, y:Int)=>x + y)
//        test(10, 20, (x, y)=>x + y)
        //test(10, 20, _ + _)

//        def test1( x:Int, y:Int ): Unit = {
//            for ( i <- 1 to x ) {
//                println("********** = " + i)
//            }
//            for ( i <- 1 to y ) {
//                println("######### = " + i)
//            }
//        }

        def test1(x:Int) = {
            for ( i <- 1 to x ) {
                println("********** = " + i)
            }

            def inner(y:Int) = {
                for ( i <- 1 to y ) {
                    println("######### = " + i)
                }

                def op( f : (Int, Int) => Int ) = {
                    f( x, y )
                }

                op _
            }

            inner _
        }

        println(test1(3)(5)(_ + _))




    }
}
